from django.http import HttpResponse
from django.shortcuts import render
from apps.feedback.models import Message


# Create your views here.
def message_form(request):
    return render(request, "message_form.html")


def message_add(request):
    item = Message()
    item.name = request.POST.get("name", "")
    item.email = request.POST.get("email", "")
    item.address = request.POST.get("address", "")
    item.content = request.POST.get("content", "")
    item.save()
    return HttpResponse("success")


def findAll():
    msg_all = Message.objects.all()
    # 查看执行sql
    for item in msg_all:
        print(item.name)


def findByName(name):
    msg_list = Message.objects.filter(name=name)
    for item in msg_list:
        print(item.name)
